<cfcomponent output="false">

	<cffunction name="GetOrganizationByID" output="false" access="remote">
		<cfargument name="id" required="true" />
 		<cfreturn createObject("component", "OrganizationDAO").read(arguments.id)>
	</cffunction>

	<cffunction name="SaveOrganization" output="false" access="remote">
		<cfargument name="obj" required="true" />
 		<cfscript>
			if( obj.ID eq 0 )
			{
				return createObject("component", "OrganizationDAO").create(arguments.obj);
			} else {
				return createObject("component", "OrganizationDAO").update(arguments.obj);
			}
		</cfscript>
	</cffunction>

	<cffunction name="DeleteByID" output="false" access="remote">
		<cfargument name="id" required="true" />
		<cfset var obj = GetOrganizationByID(arguments.id)>
		<cfset createObject("component", "OrganizationDAO").delete(obj)>
	</cffunction>

	<cffunction name="GetAllOrganizations" output="false" access="remote" returntype="virtualfooddrive-inf.com.Organization[]">
		<cfset var qRead="">
		<cfset var obj="">
		<cfset var organizations=arrayNew(1)>

		<cfquery username="#request.username#" password="#request.password#" name="qRead" datasource="nwharvest">
			select ID
			from dbo.ORGANIZATIONS
		</cfquery>

		<cfloop query="qRead">
		<cfscript>
			obj = createObject("component", "OrganizationDAO").read(qRead.ID);
			ArrayAppend(organizations, obj);
		</cfscript>
		</cfloop>
		<cfreturn organizations>
	</cffunction>

</cfcomponent>